import * as THREE from "three";
import { PositionComponent } from "../component/PositionComponent";
import { GameWorld } from "../world/World";
import { SystemBase } from "./SystemBase";

//操控

export class InputSystem extends SystemBase {
    constructor(world: GameWorld) {
        super(world);
    }
    Update(position: PositionComponent) {
        if (this.world.mouseEvent) {
            const mousePosition: THREE.Vector3 = new THREE.Vector3().fromArray([
                (this.world.mouseEvent.clientX / window.innerWidth) * 2 - 1,
                ((window.innerHeight - this.world.mouseEvent.clientY) / window.innerHeight) * 2 - 1,
                1,
            ]);
            position.value.copy(mousePosition);
        }

    }
}
